import React, { Component } from 'react'

export default class ProductListItem extends Component {
  render() {
    const { product } = this.props;
    return (
      <div style={{margin: '20px 0'}}>
        {product.title} - {product.price} - {product.inventory}
        <button style={{marginLeft: '20px'}} onClick={this.props.onAddToCartHandle} disabled={product.inventory === 0}>
          {product.inventory > 0 ? '加入购物车' : '已售罄'}
        </button>
      </div>
    )
  }
}
